<?php
/**
 *
 */
abstract class panel__model__devices {

	static public function getDevices( array $_ = array() ) {

		$Q = p()->db()->select()
		->setFrom("runcom.devices", "d")
		->addSelectEFields("d.id", "DEVICE")
		->addSelect("d.name", "title")
		->addSelectSubquery("CONCAT('VENDOR_', d.vendor_id)", "parent")
		->setOrderBy("d.name")
		;

		if( isset_or($_["select_ip"]) ) {

			$Q->addSelect("d.ip", "ip");

		}	# if

		if( isset_or($_["select_vendor"]) ) {

			$Q
			->addSelect("v.id",   "vendor_id")
			->addSelect("v.name", "vendor_title")
			->addLeftOuterJoin("runcom.vendors", "v", "v.id = d.vendor_id")
			;

		}	# if

		if( isset_or($_["where_id_in"]) ) {

			$Q->addWhere("d.id", "IN", $_["where_id_in"]);

		}	# if

		if( isset_or($_["where_vendor_id"]) ) {

			$Q->addWhere("d.vendor_id", "=", $_["where_vendor_id"]);

		}	# if

		$R = $Q->execute();

		return $R;

	}	# Function

}	# Class

/* EOF */